<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
   <link rel="stylesheet" href="__PUBLIC__/Css/Admin/common.css">
   <link rel="stylesheet" href="__PUBLIC__/Css/Admin/main.css">
   <style type="text/css">
	  .editor{
		  width:60%;
	  	  height:300px;
  		  margin-bottom:50px;
	  }
   </style>
   
   <script type="text/javascript" src="__PUBLIC__/Js/Admin/jquery.min.js"></script>
   <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
   <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.all.min.js"> </script>
   <script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
   <title>编辑景点</title>
   
   <script type="text/javascript">
       $(function(){
    	   // 提交前check
    	   checkBeforeSubmit();
       });
       
       // 提交前check
       function checkBeforeSubmit(){
    	   $("#save_button").click(function(){
    		   // 广告ID
    		   var advertisementId = $("input[name='advertisementId']").val();
    		   // 广告标题
    		   var title = $("input[name='title']").val();
    		   // 图片
    		   var imgUrl = $("input[type='file']").val();
    		   // 广告链接地址
    		   var linkAddress = $("input[name='link_address']").val();
    		   
    		   // 输入check 
    		   if($.trim(title) == ""){
    			   alert("请输入广告标题！");
    			   return false;
    		   }
    		   // 新增时check图片
    		   if($.trim(advertisementId) == ""){
    			   if($.trim(imgUrl) == ""){
        			   alert("请选择图片！");
        			   return false;
        		   }
    		   }
    		   if($.trim(linkAddress) != ""){
    			   var reg = /^(([a-zA-Z]+)(:\/\/))([a-zA-Z]+)\.(\w+)\.([\w.]+)(\/([\w]+)\/?)*(\/[a-zA-Z0-9]+\.(\w+))*(\/([\w]+)\/?)*(\?(\w+=?[\w]*))*((&?\w+=?[\w]*))*$/; 
    			   if(!reg.test(linkAddress)){
    				   alert("请重新输入链接地址！");
    				   return false;
    			   }
    		   }
    		    
    		   
    		   $("#advertisement_form").submit(); 
    	   });
       }
   </script>
</head>
<body>
<div id="forms" class="mt10">
       <div class="box">
          <div class="box_border">
            <div class="box_top">
            	<b class="pl15">{$title}</b>
            	<a class="ext_btn" onclick="location.href='javascript:history.go(-1)'" style="float:right;margin-right:10px;margin-top:5px;">返回</a>
            </div>
            <div class="box_center">
              <form action="{:U('Content/saveAdvertisement')}" class="jqtransform" id="advertisement_form" method="post" enctype="multipart/form-data">
                <input type="hidden" name="advertisementId" value="{$advertisement.id}">
               <table class="form_table pt15 pb15" style="width:100%">
                 <tr >
                  <td class="td_right"><label style="color:red;">*</label>标题：</td>
                  <td class=""> 
                    <input type="text" name="title" class="input-text lh30" size="40" value="{$advertisement.title}">
                  </td>
                 </tr>
                 
                 <tr>
                  <td class="td_right"><label style="color:red;">*</label>广告图片：</td>
                  <td class="">
                  	<input type="file" name="file" class="input-text lh30" size="10" >
                  	<if condition="$advertisement.img_path neq null">
                  	<img id="selected_img" src="__PUBLIC__/Uploads/{$advertisement.img_path}" style="border:1px solid black;height:80px; width:80px;">
                  	</if>
                  </td>
                 </tr>
                <tr>
                  <td class="td_right">链接地址：</td>
                  <td class=""> 
                    <input type="text" name="link_address" class="input-text lh30" size="40" value="{$advertisement.link_address}">
                  	  如：http://www.baidu.com
                  </td>
                </tr>
                 <tr>
                   <td class="td_right">&nbsp;</td>
                   <td class="">
                     <input type="button" name="save_button" id="save_button" class="btn btn82 btn_save2" value="保存"> 
                    <input type="reset" name="reset_button" class="btn btn82 btn_res" value="重置">
                   </td>
                 </tr>
               </table>
               </form>
            </div>
          </div>
        </div>
     </div>
</body>
</html>